package com.jmb.api.controller.system;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jmb.api.common.result.Result;
import com.jmb.api.model.entity.UserLoginLog;
import com.jmb.api.service.UserLoginLogService;
import com.jmb.api.vo.system.UserLoginLogDao;
import com.jmb.api.vo.system.UserLoginLogVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@Tag(name = "登录日志")
@RestController
@RequestMapping("user")
public class LoginLogController {
    @Autowired
    private UserLoginLogService userLoginLogService;

    @Operation(summary = "登录日志列表")
    @GetMapping("/login/log")
    public Result<IPage<UserLoginLogDao>> getLoginLogList(@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize, UserLoginLogVo userLoginLogVo) {
        IPage<UserLoginLogDao> page = new Page<>(pageNum, pageSize);
        IPage<UserLoginLogDao> list = userLoginLogService.getLoginLogList(page, userLoginLogVo);
        return Result.ok(list);
    }
}
